﻿@model BusinessManagementStudio.ViewModel.CompanyRealOrder

@{
    ViewBag.Title = "Quotation And Invoice Enquiry";
    TempData.Keep();   
}

<title>Quotation And Invoice Enquiry</title>

<h2 align="center">Quotation And Invoice Enquiry</h2>

@using (Html.BeginForm("Switch", "QuotationAndInvoice"))
{
    <table align="center">
        <tr></tr>
        <tr>
            <td width="120">Select A Company</td>
            <td>@Html.DropDownList("Company", Model.company.CompanyNameList, null, new
                                    {
                                        title = "Pick Batch",
                                        onchange = "submit();"
                                    })</td>
        </tr>
        <tr></tr>
    </table>
}

@using (Html.BeginForm("MultipleCommand", "Order", FormMethod.Post))
{    
    <div align="center"><button type="submit" name="Command" value="BackToMainMenu">Back To Main Menu</button></div>
}

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <table align="center">
        <tr>
            <td width="150">Service Order No. :</td>
            <td>@Html.TextBox("SONo")</td>
        </tr>
        <tr>
            <td width="120">Work Order No. :</td>
            <td>@Html.TextBox("WONo")</td>
            <td><button type="submit" name="Search" value="Search">Search</button></td>
        </tr>
    </table>
 
    <br align="center"/>
    if (Model.orderList != null)
    {
        <table align="center" border="1">
            <thead>
                <tr>
                    <th width="100">Service Order No.</th>
                    <th width="300">Description</th>
                    <th width="120">Location</th>
                    <th width="100">Work Order No.</th>
                    <th width="100">Quotation</th>
                    <th width="100">Invoice</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.orderList)
                {
                    <tr>
                        <td align="center">@item.ServiceOrderNo</td>
                        <td align="center">@item.Description</td>
                        <td align="center">@item.Location</td>
                        <td align="center">@item.WorkOrderNo</td>
                        @if (item.HasQuotation == true)
                        {
                            <td align="center">@Html.ActionLink(@item.QuotationNo, "JLLORDERQuotation_View", "QuotationAndInvoice", new { ServiceOrderNo = @item.ServiceOrderNo }, new { @class = "openDialog", data_dialog_id = "aboutlDialog", data_dialog_title = "JLL-(ORDER) Quotation" })</td>
                        }
                        else
                        {
                            <td align="center">@Html.ActionLink("Add", "JLLORDERQuotation", "QuotationAndInvoice", new { ServiceOrderNo = @item.ServiceOrderNo }, new { @class = "openDialog", data_dialog_id = "aboutlDialog", data_dialog_title = "JLL-(ORDER) Quotation" })</td>
                        }
                        @if (item.HasInvoice == true)
                        {
                            <td align="center">@Html.ActionLink(@item.InvoiceNo, "JLLORDERInvoice_View", "QuotationAndInvoice", new { ServiceOrderNo = @item.ServiceOrderNo }, new { @class = "openDialog", data_dialog_id = "aboutlDialog", data_dialog_title = "JLL-(ORDER) Invoice" })</td>
                        }
                        else
                        {
                            <td align="center">@Html.ActionLink("Add", "JLLORDERInvoice", "QuotationAndInvoice", new { ServiceOrderNo = @item.ServiceOrderNo }, new { @class = "openDialog", data_dialog_id = "aboutlDialog", data_dialog_title = "JLL-(ORDER) Invoice" })</td>
                        }
                    </tr>
                }
            </tbody>
        </table>
    }
}

<link href='~/Scripts/jquery-ui.css' rel='stylesheet'>
<script type="text/javascript" src="~/Scripts/jquery-2.1.0.js"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui.js"></script>
<script type="text/javascript">
    $.ajaxSetup({ cache: false });

    $(document).ready(function () {
        $(".openDialog").click(function (e) {
            e.preventDefault();

            $("<div></div>")
                    .addClass("dialog")
                    .attr("id", $(this)
                    .attr("data-dialog-id"))
                    .appendTo("body")
                    .dialog({
                        title: $(this).attr("data-dialog-title"),
                        close: function () { $(this).remove(); },
                        modal: true,
                        height: 800,
                        width: 900,
                        left: 0

                    })
                    .load(this.href);
        });

        $(".close").click(function (e) {
            e.preventDefault();
            $(this).closest(".dialog").dialog("close");
        });
    });
</script>